const tokenKey = 'token'

export const getToken = () => {
  return uni.getStorageSync(tokenKey)
}

export const getAccessToken = () => {
  return uni.getStorageSync(tokenKey)?.access_token
}

export const getRefreshToken = () => {
  return uni.getStorageSync(tokenKey)?.refresh_token
}

export const setToken = (token) => {
  uni.setStorageSync(tokenKey, token);
}

export const clearToken = () => {
  uni.removeStorageSync(tokenKey);
}

export const isLogin = () => {
  return Boolean(getToken())
}

export default {
  getToken,
  getAccessToken,
  getRefreshToken,
  setToken,
  clearToken,
  isLogin
}